﻿using Prism.Commands;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wpf.Netdisk.Extensions;
using Wpf.Netdisk.Models;
using Wpf.Netdisk.ViewModels.Base;

namespace Wpf.Netdisk.ViewModels.MainListItem
{
    /// <summary>
    /// 传输
    /// </summary>
    public class TransfersViewModel : NavigationViewModel
    {
        #region 属性

        private ObservableCollection<MenuBar> menuBars;
        private readonly IRegionManager _regionManager;

        public ObservableCollection<MenuBar> MenuBars
        {
            get { return menuBars; }
            set { menuBars = value; RaisePropertyChanged(); }
        }
        /// <summary>
        /// 导航属性
        /// </summary>
        public DelegateCommand<MenuBar> NavigateCommand { get; private set; }
        #endregion
        public TransfersViewModel(IContainerProvider containerProvider, IRegionManager regionManager) : base(containerProvider)
        {
            CreateMenuBar();
            _regionManager = regionManager;
            NavigateCommand = new DelegateCommand<MenuBar>(Navigate);
        }
        private void Navigate(MenuBar obj)
        {
            if (obj == null || string.IsNullOrWhiteSpace(obj.NameSpace))
            {
                return;
            }
            NavigationParameters param= new NavigationParameters();

            var regions = _regionManager.Regions[PrismManager.ChildrenViewRegionName];
            regions.RequestNavigate(obj.NameSpace, param);
        }
        void CreateMenuBar()
        {
            MenuBars = new ObservableCollection<MenuBar>();
            //Todo 替换为接口获取
            MenuBars.Add(new MenuBar() { Icon = "TrayArrowDown", Title = "正在下载", NameSpace = "TrayArrowDownView" });
            MenuBars.Add(new MenuBar() { Icon = "TrayArrowUp", Title = "正在上传", NameSpace = "TrayArrowUpView" });
            MenuBars.Add(new MenuBar() { Icon = "CheckCircleOutline", Title = "传输完成", NameSpace = "CheckCircleOutlineView" }); 
        }
    }
}
